﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using DAO;

namespace BUS
{
    public class QuanBUS
    {
        #region 1.Retrieving
        public static List<QuanDTO> SelectQuanAll()
        {
            return QuanDAO.SelectQuanAll();
        }
        public static bool CheckIDQuanExits(string maQuan)
        {
            bool isExits = false;
            if (QuanDAO.SellectQuanByIndex(maQuan).Count == 1)
            {
                isExits = true;
            }
            return isExits;
        }
        #endregion
        #region 2.Updating
        public static bool UpdateQuan(QuanDTO quan)
        {
            bool isSucessful = false;
            if (QuanDAO.CheckMaQuanExits(quan.MaQuan) == false)
            {
                return isSucessful;
            }
            return QuanDAO.UpdateQuan(quan);

        }
        #endregion
        #region 3.Deleting
        public static bool DeleteQuan(string maQuan)
        {
            bool isSucessful = false;
            if (QuanDAO.CheckMaQuanExits(maQuan) == false)
            {
                return isSucessful;
            }
            return QuanDAO.DeleteQuan(maQuan);

        }
        #endregion
        #region 4.Inserting
        public static bool InsertQuan(QuanDTO quan)
        {
            bool isSucessful = false;
            if (QuanDAO.CheckMaQuanExits(quan.MaQuan) == true)
            {
                return isSucessful;
            }
            return QuanDAO.InsertQuan(quan);
        }
        #endregion

    }

}
